// pages/information/information.js
var util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbar: ['财务部', '研发部', '人力组', "综合组","法务组"],
    //count:[0,2,3],                                  //记录不同状态记录的数量
    currentTab: 0,
    icon: ['icon-caiwu', 'icon-yanfa', 'icon-human-resources', 'icon-zonghe','icon-fawubu'],
    iconType: ['add2'],
    list: [
        {
          //index:'',
         // id: '0',
          explain: '不按时一天扣一分',
          assess: '相关部门对财务部部门的满意度',
          weight: '10',
          number:''
          
        },
        {
         // index:'',
          //id: '1',
          explain: '不按时一天扣一分',
          assess: '相关部门对财务部部门的满意度',
          weight: '15',
          number: ''
        }
    ],
    deduction:[{}],
    isDisabled: false,
    loading: false
    },
  addDeduction:function(){
    var deduction = this.data.deduction;
    var newData = {};
    deduction.push(newData);//实质是添加lists数组内容，使for循环多一次
    if (deduction.length > 3){
      wx.showToast({
        title: '最多输入3项扣分项',
        icon: 'none',
        duration: 2000
      });
  　　//模拟取消
  　　setTimeout(function () {
        wx.hideToast();
  　　}, 2000);
      this.setData({
        isDisabled: true
      })
    }else{
      this.setData({
        isDisabled: false,
        deduction: deduction,
      })
    };
    
  },
  setLoading: function (e) {
    this.setData({
      loading: !this.data.loading
    })
  },
  checkNumber: function(e){
    var number = e.detail.value;
    console.log(number)
    var score = e.currentTarget.id;
    var weight = e.currentTarget.dataset.weight;
    console.log(weight);
    var index = "list[" + e.currentTarget.id + "].number"; 
    if (number < weight*0.6 && number != ''){
      this.setData({
        [index]:true
      })
    }else{
      this.setData({
        [index]: false
      });
    }
    
  },
  //响应点击导航栏
  navbarTap: function (e) {
    var that = this;
    this.setData({
      currentTab: e.currentTarget.dataset.id
    })
  },
  getlist() {
    var that = this,  
    currentTab;
    if (that.data.currentTab == 0) {    //这里的this.data.navi是我上面data里面声明的navi     
      currentTab = 1      //上线和未上线后台给了我is_online=1或者0，我将招聘中的navi=0    
    } else if (that.data.currentTab == 1) {
      currentTab = 2
    } else if (that.data.currentTab == 2) {
      currentTab = 3
    } else if (that.data.currentTab == 3) {
      currentTab = 4
    }else{
      currentTab = 5
    }
    //wx.request({
      //url: app.globalData.url + '/rc/Position/release_list?department=' + currentTab,
      // header: {
      //   'content-type': 'application/json' // 默认值     
      // },
    //   success(res) {
    //     that.setData({
    //       list: res.data.data  //我要将list这个碗里放入后台请求的is_online=0或者1这些东西        
    //     })
    //   }
    //})
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var timestamp = util.formatTime(new Date());
    var date = new Date(timestamp);
    //获取年份  
    var year = date.getFullYear();
    this.setData({
      year:year
    });
    this.getlist();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})